package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.ConsultBean;
import com.project.bean.EventBean;
import com.project.dao.ConsultDao;
import com.project.service.ConsultService;
import com.project.service.EventService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 会商
 */

@Service
@Transactional
public class ConsultServiceImpl extends ServiceImpl<ConsultDao, ConsultBean> implements ConsultService {

    private EventService eventService;


    /**
     * 显示所有会商信息
     * @return
     */
    @Override
    public List<EventBean> findAllConsult() {
        QueryWrapper<EventBean> wrapper = new QueryWrapper<>();
        wrapper.eq("f_eventStage","无法解决，申请专家会商");
        return eventService.list(wrapper);
    }

    /**
     * 添加会商
     * @param consultBean
     */
    @Override
    public void addConsult(int eventId,ConsultBean consultBean) {
        this.baseMapper.addConsult(consultBean);
        this.baseMapper.update(eventId,consultBean.getConResult());
    }



    /**
     * 根据事件id去将会商结果修改成专家建议
     * @param eventId
     * @param conResult
     */
    @Override
    public void update(int eventId, String conResult) {
        this.baseMapper.update(eventId,conResult);
    }


}
